home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2801 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  63 lines

  1. Newsgroups: comp.lang.c++
  2. Path: twisto.eng.hou.compaq.com!news
  3. From: Saurabh Dixit <saurabhd@bangate.compaq.com>
  4. Subject: Re: destructots and VC++
  5. Message-ID: <30FFEDF3.2BC9@bangate.compaq.com>
  6. Sender: news@twisto.eng.hou.compaq.com (System Administrator)
  7. Mime-Version: 1.0
  8. X-Mailer: Mozilla 2.0b5 (WinNT; I)
  9. Content-Type: text/plain; charset=us-ascii
  10. Organization: Compaq Computer Corporation
  11. Date: Fri, 19 Jan 1996 19:16:03 GMT
  12. References: <4doem9$7a8@zephyr.ens.tek.com>
  13. X-Nntp-Posting-Host: 172.18.176.8
  14. Content-Transfer-Encoding: 7bit
  15.  
  16. Err...
  17. I wasn't even aware that constructors/destructors could 
  18. be invoked directly on objects from outside.
  19. In fact I remember a few years back when I was in school
  20. I tried to call the constructor on one of my objects to
  21. re-initialize it and when my gnu++ croaked someone responded
  22. to my query in this newsgroup to set me straight.
  23.  
  24. Regarding VC++ I know the following works in 4.0
  25.  
  26. class A {
  27.     int a;
  28.     int b;
  29. public:
  30.     A (int _a) 
  31.     {
  32.         a = 4;
  33.         A ();
  34.     }
  35.     A () 
  36.     {
  37.         b = 4;
  38.     };
  39. };
  40.  
  41. So from within the class, calling a constructor seems to work.
  42. So maybe I'm thinking constructors and destructors can be
  43. explicitly invoked from within the class but not from outside?
  44. Anyone care to comment?
  45.  
  46. Of course, I may be full of .... since the original poster
  47. claims calling a destructor explicitly from outside is 
  48. supposed to work as it is the standard.
  49.  
  50. Thank you for your time
  51. saurabh
  52. -- 
  53. Saurabh Dixit
  54. "All opinions are always my own..."
  55. Compaq Computer Corporation
  56. ----------------------------------------------------------------
  57. --------
  58. Thou who sneezes without kerchief takes matters in own hands.
  59.             - SomeoneIOnceNew
  60. ----------------------------------------------------------------
  61. -------- 
  62. xxxx
  63.